<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-05 15:16:04
 * @LastEditTime : 2020-01-10 16:06:17
 * @LastEditors  : Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style type="text/css">
        .row {
            padding: 10px 10px 0 10px;
        }

        .row:last-child {
            padding-bottom: 10px;
        }

        .row>div {
            background: #fff;
            overflow: hidden;
            border-radius: 4px;
            padding: 10px;
            font-size: 14px;
        }

        .pr {
            color: #cd1b21;
        }

        .pg {
            color: #1aaf1e;
        }

        .ov {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 14px;
        }

        .rg {
            color: #969799;
            text-align: right;
        }

        .money {
            line-height: 40px;
        }

        .money span {
            font-size: 26px;
            font-weight: 700;
            margin-right: 5px;
        }

        .pd {
            line-height: 28px;
        }

        .pd span {
            color: #969799;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="init-full">
            <van-nav-bar class="head" title="账户明细" left-arrow @click-left="onClickLeft">
                <div slot="right" class="head-right">
                    <span @click="showSearch = true;">
                        <img src="../image/search.png" />
                    </span>
                </div>
            </van-nav-bar>
            <div class="body-no-bottom" :class="userId?'body-no-bottom':'body-with-bottom'">
                <div class="content">
                    <van-list v-model="listLoading" :finished="listFinished" finished-text="没有更多了" @load="listOnLoad">
                        <div class="row" v-for="(row,index) in dataList" @click="intoDetail(row)">
                            <div>
                                <van-row gutter="20">
                                    <van-col span="12" class="ov" :class="row.BType == '支出'?'pr':'pg'">{{row.BType}}
                                    </van-col>
                                    <van-col span="12" class="rg">{{row.CreateTime}}</van-col>
                                </van-row>
                                <div class="money"><span>{{row.DMoney}}</span>元</div>
                                <div class="pd">来<span
                                        style="visibility: hidden;">透明</span>源：&nbsp;&nbsp;&nbsp;&nbsp;<span>{{row.FYY}}</span>
                                </div>
                                <div class="pd">账<span
                                        style="visibility: hidden;">透明</span>期：&nbsp;&nbsp;&nbsp;&nbsp;<span>{{row.PeriodName}}</span>
                                </div>
                                <div class="pd">支付说明：&nbsp;&nbsp;&nbsp;&nbsp;<span>{{row.FRemarks}}</span></div>
                            </div>
                        </div>
                    </van-list>
                </div>
                <van-loading v-if="showLoading" />
            </div>
            <div class="bottom" v-show="!userId" style="height: 50px;">
                <van-button type="primary" block style="border-radius: 0;height:100%;" :disabled="!dataList.length" @click="showPay = true;">提现
                </van-button>
            </div>
        </div>
        <van-popup v-model="showSearch" round position="bottom">
            <div>
                <van-cell title="开始时间" :value="searchData.S_SDate" @click="openDate(1)">
                </van-cell>
                <van-cell title="结束时间" :value="searchData.S_EDate" @click="openDate(2)">
                </van-cell>
            </div>
            <div class="btn-padding">
                <van-button type="primary" block style="border-radius: 0;" @click="searchList">查询</van-button>
            </div>
        </van-popup>


        <van-popup v-model="showDate" round position="bottom">
            <van-datetime-picker v-model="currentDate" type="date" @confirm="confirmDate" @cancel="cancelDate"
                cancel-button-text="清空" />
        </van-popup>

        <van-dialog v-model="showPay" close-on-click-overlay @confirm="moneyPay">
            <div style="padding-top:30px;">
                <van-field label="提现金额" placeholder="请输入提现金额"></van-field>
            </div>
        </van-dialog>

    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        //$('.init-full').show();

        var userInfo = FLD.getUserInfo();

        var userId = api.pageParam.userId;

        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                showSearch: false,
                listLoading: false,
                listFinished: true,
                userId: userId || 0,
                dataList: [],
                pageIndex: 1,
                pageSize: 20,
                currentDate: new Date(),
                showDate: false,
                showPay: false,
                searchData: {
                    S_SDate: '',
                    S_EDate: ''
                }

            },
            created: function () {

                // var appTop = parseInt(window.localStorage.getItem('safeAreaTop'));
                // var appBottom = parseInt(window.localStorage.getItem('safeAreaBottom'));
                // setTimeout(function () {
                //     $('.body-no-bottom').css({
                //         'height': 'calc(100% - ' + (appTop + 40) + 'px)'
                //     })
                //     $('.body-with-bottom').css({
                //         'height': 'calc(100% - ' + (appTop + 40 + 50) + 'px)'
                //     })
                // }, 200)

                this.getPayRecord();
            },
            methods: {
                getPayRecord() {
                    var that = this;
                    that.showLoading = true;
                    var obj = null
                    if (userId) {
                        obj = {
                            S_Pageindex: that.pageIndex,
                            S_PageSize: that.pageSize,
                            S_SDate: that.searchData.S_SDate,
                            S_EDate: that.searchData.S_EDate,
                            P_UserID: userId
                        }
                    } else {
                        obj = {
                            S_Pageindex: that.pageIndex,
                            S_PageSize: that.pageSize,
                            S_SDate: that.searchData.S_SDate,
                            S_EDate: that.searchData.S_EDate
                        }
                    }

                    FLD.ajax('AP_AccountDeN', obj, function (res) {
                        that.showLoading = false;
                        that.listFinished = false;
                        that.dataList = res.ds;
                    })
                },
                listOnLoad(index) {
                    var that = this;
                    that.pageIndex++;
                    var obj = null
                    if (userId) {
                        obj = {
                            S_Pageindex: that.pageIndex,
                            S_PageSize: that.pageSize,
                            S_SDate: that.searchData.S_SDate,
                            S_EDate: that.searchData.S_EDate,
                            P_UserID: userId
                        }
                    } else {
                        obj = {
                            S_Pageindex: that.pageIndex,
                            S_PageSize: that.pageSize,
                            S_SDate: that.searchData.S_SDate,
                            S_EDate: that.searchData.S_EDate
                        }
                    }
                    FLD.ajax('AP_AccountDeN', obj, function (res) {
                        that.listLoading = false;
                        if (res.ds.length == 0) {
                            that.listFinished = true;
                        }
                        that.dataList = that.dataList.concat(res.ds);
                    })
                },
                intoDetail(row) {
                    var that = this;
                    if (row.YWType == 1 || row.YWType == 2) {
                        api.openWin({
                            name: '结算明细查询_0',
                            url: 'common/formConfigReport.html',
                            reload: true,
                            slidBackEnabled: false,
                            pageParam: {
                                objName:'结算明细查询',
                                formData: {
                                    BranchID:row.BranchID,
                                    JS_PeriodID:row.JS_PeriodID,
                                    ClientTreeID:row.ClientTreeID,
                                    ClientID:row.ClientID
                                }
                            }
                        })
                    }else if(row.YWType == 99){
                        api.openWin({
                            name: '商城收益明细报表_0',
                            url: 'common/formConfigReport.html',
                            reload: true,
                            slidBackEnabled: false,
                            pageParam: {
                                objName:'商城收益明细报表',
                                formData: {
                                    BranchID:row.BranchID,
                                    JS_PeriodID:row.JS_PeriodID,
                                    ClientTreeID:row.ClientTreeID,
                                    ClientID:row.ClientID,
                                    V_UserID:userId || FLD.getUserInfo().UserID
                                }
                            }
                        })
                    }else if(row.YWType == 3){
                        api.openWin({
                            name: '送货明细查询_0',
                            url: 'common/formConfigReport.html',
                            reload: true,
                            slidBackEnabled: false,
                            pageParam: {
                                objName:'送货明细查询',
                                formData: {
                                    VJS_PeriodID:row.JS_PeriodID,
                                    V_UserID:row.UserID
                                }
                            }
                        })
                    }
                },
                searchList() {
                    var that = this;
                    that.showSearch = false;

                    that.pageIndex = 1;

                    this.getPayRecord();
                },
                moneyPay() {
                    var that = this;
                    that.showPay = false;
                },
                openDate(index) {
                    dateIndex = index;
                    this.currentDate = new Date()
                    this.showDate = true;
                },
                confirmDate(value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = FLD.getFormatDate(value).split(' ')[0]
                    } else {
                        this.searchData.S_EDate = FLD.getFormatDate(value).split(' ')[0]
                    }
                    this.showDate = false;
                },
                cancelDate(value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = ''
                    } else {
                        this.searchData.S_EDate = '';
                    }
                    this.showDate = false;
                },
                onClickLeft() {
                    api.closeWin();
                }
            }
        })
    };
</script>

</html>